package page6;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Ques1611 {
	
	public void go(){
		Scanner scan = new Scanner(System.in);
		int n,l,r,sum;
		int[] temp = new int[100010];
		l = 0;
		r = 0;
		sum = 0;
		List<Integer> list = new ArrayList<>();
		for (int i = 3; i <= 100000; i++) {
			sum = 0;
			for (int j = 1; j < Math.sqrt(i); j++) {
				if(i % j == 0){
					sum += (j + i / j) % 520623;
				}
				if(j * j == i){
					sum += j;
				}
				temp[i] = (temp[i + 1] + sum) % 520623;
			}
		}
		
		n = scan.nextInt();
		while(scan.hasNext()){
			while(n != -1){
				l = scan.nextInt();
				r = scan.nextInt();
				for(int i = 0;i <= n;i ++){
					int ans = temp[r] - temp[l - 1] + 520623;
				}
				sum = sum % 520623;
				System.out.println(sum);
				n = scan.nextInt();
			}
			return;
		}
	}
	
	public static void main(String[] args) {
		new Ques1611().go();
	}
}
